package config

type Log struct {
	StorageLocation     string `mapstructure:"storageLocation"`
	RotationTime        uint   `mapstructure:"rotationTime"`
	RemainRotationCount uint   `mapstructure:"remainRotationCount"`
	RemainLogLevel      int    `mapstructure:"remainLogLevel"`
	IsStdout            bool   `mapstructure:"isStdout"`
	IsJson              bool   `mapstructure:"isJson"`
	IsSimplify          bool   `mapstructure:"isSimplify"`
	WithStack           bool   `mapstructure:"withStack"`
}

type Discovery struct {
	Enable string `mapstructure:"enable"`
	Etcd   Etcd   `mapstructure:"etcd"`
}

type Etcd struct {
	RootDirectory string   `mapstructure:"rootDirectory"`
	Address       []string `mapstructure:"address"`
	Username      string   `mapstructure:"username"`
	Password      string   `mapstructure:"password"`
}

type Prometheus struct {
	Enable bool `mapstructure:"enable"`
	Port   int  `mapstructure:"ports"`
}

type API struct {
	Api struct {
		ListenIP string `mapstructure:"listenIP"`
		Port     int    `mapstructure:"ports"`
	} `mapstructure:"api"`
	Prometheus struct {
		Enable     bool   `mapstructure:"enable"`
		Port       int    `mapstructure:"port"`
		GrafanaURL string `mapstructure:"grafanaURL"`
	} `mapstructure:"prometheus"`
}

type Gateway struct {
	ListenIP string `mapstructure:"listenIP"`
	RPC      struct {
		RegisterIP string `mapstructure:"registerIP"`
		Port       int    `mapstructure:"port"`
	} `mapstructure:"rpc"`
	Websocket struct {
		Port                int `mapstructure:"port"`
		WebsocketMaxConnNum int `mapstructure:"websocketMaxConnNum"`
		WebsocketMaxMsgLen  int `mapstructure:"websocketMaxMsgLen"`
		WebsocketTimeout    int `mapstructure:"websocketTimeout"`
	} `mapstructure:"websocket"`
	Prometheus Prometheus `mapstructure:"prometheus"`
}

type Share struct {
	Secret           string          `mapstructure:"secret"`
	RpcRegisterName  RpcRegisterName `mapstructure:"rpcRegisterName"`
	AdminUserID      []string        `mapstructure:"adminUserID"`
	MultiLoginPolicy int             `mapstructure:"multiLoginPolicy"`
}

type RpcRegisterName struct {
	Gateway string `mapstructure:"gateway"`
	Push    string `mapstructure:"push"`
	Message string `mapstructure:"message"`
}

func (r *RpcRegisterName) GetServiceNames() []string {
	return []string{
		r.Gateway,
		r.Push,
		r.Message,
	}
}
